    //
//  PerumalViewController.m
//  TabNav
//
//  Created by Kalyan Mudumbai on 8/30/10.
//  Copyright 2010 GOLDMAN SACHS. All rights reserved.
//

#import "PerumalViewController.h"
#import "InfoViewController.h"


@implementation PerumalViewController
@synthesize imageView;
@synthesize imageNameMap;

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.*/
- (void)viewDidLoad {
	NSLog(@"PV : view did load...");
	
	// also you can use initWithObjectAndKeys: @"string", [NSNumber numberWithInt:x] for the key
	imageNameMap = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"bhishma.png",@"1",@"gajendra.png",@"2",@"hayagrivabrahma.png",@"3",
					@"matsya.png",@"4",@"narasimha.png",@"5",@"rama.png",@"6",@"skrishna.png",@"7",
					@"vamana.png",@"8",@"varaha.png",@"9",@"vishnu.png",@"10",nil];
	
    [super viewDidLoad];
}

-(void) viewWillAppear:(BOOL)animated {
	NSLog(@"PV: View will appear with map %@",imageNameMap);
	NSUInteger no = arc4random()%10;
	NSString * key = [NSString stringWithFormat:@"%d",no];
	NSString * imageName = [imageNameMap objectForKey:key];
	NSLog(@"Image name is: %@", imageName);
	if(imageName == nil) {
		imageName = @"sitarama.jpg";
	}
	UIImage * newImage = [UIImage imageNamed:imageName];
	imageView.image = newImage;
	
	//[newImage release];
	//[key release];
	[super viewWillAppear:animated];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
	self.imageView = nil;
	self.imageNameMap = nil;
}


- (void)dealloc {
	[imageView release];
	[imageNameMap release];
    [super dealloc];
}


@end
